package leetcode.offer;

/**
 * ClassName: MinNumberInRotatedArray
 * Description: leetcode-剑指offer 11. 旋转数组的最小数字
 * date: 2021-11-01 18:30
 *
 * @author liyifan
 */
public class MinNumberInRotatedArray {
    public int minArray(int[] numbers) {
        // todo 看这里的二分
        int left = 0;
        int right = numbers.length - 1;
        while (left < right) {
            int mid = (left + right) >> 1;
            if (numbers[mid] > numbers[right])
                left = mid + 1;
            else if(numbers[mid] < numbers[right])
                right = mid;
            else
                right--;
        }
        return numbers[left];
    }

}
